package com.software.cool.rabbitmq.receive;

import com.software.cool.mapper.RabbitmqMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component
public class OnlineReceiveListener {

    @Resource
    private RabbitmqMapper rabbitmqMapper;
//    @Resource
//    private StringRedisTemplate stringRedisTemplate;

    /**
     * 设备心跳包
     * @param message
     */
//    @RabbitListener(queuesToDeclare = @Queue(RabbitQueue.AI_PAD_HEART_RATE_QUEUE))
//    public void padHeartRateProcess(String message) {
//        try {
//            QueueMessageVO<PadInfo> vo= JSON.parseObject(message,QueueMessageVO.class);
//            if(vo!=null && CommonUtils.isNotBlank(vo.getPadUuid()) && vo.getData()!=null){
//                stringRedisTemplate
//                        .opsForValue()
//                        .set(StrFormatter.format(CommonContant.ON_LINE_PAD_REDIS_KEY,vo.getPadUuid()),JSON.toJSONString(vo.getData()),120, TimeUnit.SECONDS);
//                SysPad sysPad=sysPadMapper.getByPadUuid(vo.getPadUuid());
//                /**判断是否存在设备数据**/
//                if(sysPad==null){
//                    sysPad=new SysPad();
//                    BeanUtils.copyProperties(vo.getData(),sysPad);
//                    sysPad.setUseStatus("normal");
//                    sysPad.setCreateDate(new Date());
//                    sysPad.setCreateId(0L);
//                    sysPad.setUpdateDate(new Date());
//                    sysPad.setUpdateId(0L);
//                    sysPadMapper.insert(sysPad);
//                }
//            }
//            log.info("ai_pad_heart_rate_queue ReceiveListener message:"+message);
//        } catch (Exception e) {
//            log.error(e.getMessage(),e);
//        }
//
//    }

//    @RabbitListener(queuesToDeclare = @Queue(RabbitQueue.AI_ADMIN_QUEUE))
    public void appToAdminProcess(String message) {
        try {
            log.info("ai_admin_queue ReceiveListener message:"+message);
//            rabbitmqMapper.sendWork(message);
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }

    }
}
